import { defineConfig } from 'vite' // 动态配置函数
import { createVuePlugin } from 'vite-plugin-vue2'
import { resolve } from 'path'

const crossOriginIsolation = () => ({
	name: 'configure-server',
	configureServer(server) {
	  server.middlewares.use((_req, res, next) => {
		res.setHeader("Cross-Origin-Opener-Policy", "same-origin");
		res.setHeader("Cross-Origin-Embedder-Policy", "require-corp");
		next();
	  });
	}
  });
export default () =>
	defineConfig({
		plugins: [createVuePlugin()],
		base: "/audiotest/",
		resolve: {
            // 别名
			alias: [
				{
					find: '@',
					replacement: '/src'
				}
			]
		},
		server: {
			host: "0.0.0.0" ,
			proxy: {
			  "/api_audiotext": {
				target: "https://accktv.sd-rtn.com",
				changeOrigin: true,
				rewrite: (path) => path.replace(/^\/api_audiotext/, ""),
			  },
			},
		},
	})

